<script setup>
	
	import { onShow, onHide } from '@dcloudio/uni-app'
	
	
	const verifyNetwork = ({ networkType }) => {
		const pages = getCurrentPages();
		const path = 'pages/other/network';
		const currentPage = pages?.[pages.length - 1];
		if (['none', 'offline'].includes(networkType)) {
			if (currentPage?.route !== path) uni.$fui.href(`/${path}`, null, false, false);
			
		} else {
			const lastCurrentPage = pages?.[pages.length - 2];
			if (currentPage?.route === path) {
				lastCurrentPage?.route ? uni.reLaunch({ url: `/${lastCurrentPage.route}` }) : uni.navigateBack();
			};
		};
	};
	
	onShow(() => {
		uni.getNetworkType({ success: verifyNetwork })
		uni.onNetworkStatusChange(verifyNetwork)
	})
	
	onHide(() => uni.offNetworkStatusChange(verifyNetwork))
</script>

<style lang="scss">
    @import "@/js_sdk/a-hua-unocss/index.scss";
	@import "@/style/three-dots.css";
	@import '@/style/iconfont.css';
	@import '@/style/fui.css';
	@import '@/uni_modules/m-style/install.scss';
	@import "./style/app.scss";
</style>
